package team.future.joke.service.impl;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import team.future.joke.dao.BaseMongoDao;
import team.future.joke.entity.JokeStore;
import team.future.joke.service.JokeStoreService;

/**
 * Title: JokeStoreServiceImpl.java<br>
 * Description: <br>
 * Copyright (c) 未来工作室版权所有 2015    <br>
 * Create DateTime: 2015年9月13日 上午11:16:46 <br>
 * @author futurezhu
*/
@Service("jokeStoreService")
public class JokeStoreServiceImpl implements JokeStoreService {

	@Autowired
	private BaseMongoDao<JokeStore> jokeStoreDao;

	@Override
	public void insertStore(JokeStore store) {
		jokeStoreDao.insertObject(store);
	}

	@Override
	public void deleteStore(String jokeId, String uid) {
		jokeStoreDao.deleteObject(query(where("jokeId").is(jokeId).and("uid").is(uid)));
	}

	@Override
	public List<JokeStore> getJokeStores(String uid) {
		return jokeStoreDao.getObjectList(query(where("uid").is(uid)));
	}

}
